//knex操作数据库
const { mysql } = require('../qcloud')

module.exports = async (ctx) => {
    const { openid, skey, session_key, user_info } = ctx.request.body
    console.log("======openid", openid)
    console.log("======skey", skey)
    console.log("======session_key", session_key)
    console.log("======user_info", user_info)
    try {
        await mysql('myuserinfo').insert({
            openid, skey, session_key, user_info
        })

        ctx.state.data = {
            code: 0,
            msg: "success"
        }
        console.log("添加xieh执行成功")
    } catch (e) {
        ctx.state = {
            code: -1,
            data: {
                msg: "添加失败" + e.sqlMessage
            }
        }
        console.log("执行错误")
    }

}